package io.jee.medusa.orm.pager;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@SuppressWarnings("unused")
@JsonIgnoreProperties({"pagenum", "pagesize", "upage", "first", "next", "last", "totalpage", "totalrecord", "datas"})
public class Pager<T> {
	private int pagenum = 1;
	private int pagesize = 10;
	private int upage;
	private int first = 1;
	private int next;
	private int last;
	private int totalpage = 1;
	private int totalrecord = 0;
	private List<T> datas;

	private List<T> data;
	private int offset;
	private int total;
	private int pageItems = 10;

	public Pager() {
	}

	public Pager(int pagenum, int pageSize) {
		this.pagenum = pagenum;
		this.pagesize = pageSize;
	}

	public int getPagenum() {
		return pagenum;
	}

	public void setPagenum(int pagenum) {
		this.pagenum = pagenum;
		this.offset = pagenum;
	}

	public int getPagesize() {
		return pagesize;
	}

	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
		this.pageItems = pagesize;
	}

	public List<T> getDatas() {
		return datas;
	}

	public void setDatas(List<T> datas) {
		this.datas = datas;
	}

	public int getTotalpage() {
		return totalpage;
	}

	public void setTotalpage(int totalpage) {
		this.totalpage = totalpage;
	}

	public int getTotalrecord() {
		return totalrecord;
	}

	public void setTotalrecord(int totalrecord) {
		this.totalrecord = totalrecord;
	}

	public int getUpage() {
		return upage;
	}

	public void setUpage(int upage) {
		this.upage = upage;
	}

	public int getFirst() {
		return first;
	}

	public void setFirst(int first) {
		this.first = first;
	}

	public int getNext() {
		return next;
	}

	public void setNext(int next) {
		this.next = next;
	}

	public int getLast() {
		return last;
	}

	public void setLast(int last) {
		this.last = last;
	}

	public List<T> getData() {
		return datas;
	}

	public void setData(List<T> data) {
		this.datas = data;
	}

	public int getOffset() {
		return this.getPagenum();
	}

	public void setOffset(int offset) {
		this.offset = offset;
		this.pagenum = ( offset + this.pagesize ) / this.pagesize;
	}

	public int getTotal() {
		return this.totalrecord;
	}

	public void setTotal(int total) {
		this.total = total;
		this.totalrecord = total;
	}

	public int getPageItems() {
		return this.getPagesize();
	}

	public void setPageItems(int pageItems) {
		this.pageItems = pageItems;
		this.pagesize = pageItems;
	}

}
